import request from '@/utils/request'

// 查询【设备】列表
export function listDevice(query) {
  return request({
    url: '/device/device/list',
    method: 'get',
    params: query
  })
}

// 查询【设备】详细
export function getDevice(id) {
  return request({
    url: '/device/device/' + id,
    method: 'get'
  })
}

// 新增【设备】
export function addDevice(data) {
  return request({
    url: '/device/device',
    method: 'post',
    data: data
  })
}

// 修改【设备】
export function updateDevice(data) {
  return request({
    url: '/device/device',
    method: 'put',
    data: data
  })
}

// 删除【设备】
export function delDevice(id) {
  return request({
    url: '/device/device/' + id,
    method: 'delete'
  })
}

// 查询设备类别列表
export function getDeviceTypes() {
  return request({
    url: '/device/type/optionselect',
    method: 'get'
  })
}

// 查询校验已绑定解析规则
export function getAuthPoint(deviceId) {
  return request({
    url: '/device/pointRuleRef/authPoint/' + deviceId,
    method: 'get'
  })
}

// 保存校验已绑定解析规则
export function updateAuthPoint(data) {
  return request({
    url: '/device/pointRuleRef/authPoint',
    method: 'put',
    params: data
  })
}


export function listDeviceBoard(query) {
  return request({
    url: '/device/board/list',
    method: 'get',
    params: query
  })
}

export function listDeviceBoardRef(deviceId,deviceName) {
  return request({
    url: '/device/board/ref/list',
    method: 'get',
    params: { deviceId: deviceId,deviceName: deviceName }
  })
}

export function addDeviceBoardRef(data) {
  return request({
    url: '/device/board/ref',
    method: 'post',
    data: data
  })
}


export function getDeviceBoards(deviceId) {
  return request({
    url: '/device/board/' + deviceId,
    method: 'get'
  })
}
// 修改【设备主从测点】
export function updateDeviceMs(data) {
  return request({
    url: '/device/device/editMsCode/',
    method: 'put',
    data: data
  })
}

//手动测试
export function testCommand(deviceId) {
  return request({
    url: '/device/device/test/' + deviceId,
    method: 'get'
  })
}

// 查询【设备历史数据】列表
export function listDeviceData(query) {
  return request({
    url: '/device/data/list',
    method: 'get',
    params: query
  })
}
//设备历史数据折线图
export function hisData(id) {
  return request({
    url: '/device/device/hisData/'+id,
    method: 'get'
  })
}
//重置硬件配置
export function resetHardWareConfig() {
  return request({
    url: '/device/device/resetHardWareConfig',
    method: 'get'
  })
}

export function getDeviceStatus() {
  return request({
    url: '/device/device/getDeviceStatus',
    method: 'get'
  })
}